dofile (getScriptPath() .. "\\..\\processor\\processor.lua")

if not menu then

menu = {}


dofile (getScriptPath() .. "\\..\\processor\\log.lua")
dofile (getScriptPath() .. "\\..\\lib\\lib.lua")


if not script_name then script_name = string.gsub(string.gsub(debug.getinfo(1).short_src, "%.[^%.]*$", ""), "^.*[\\/]", "") end


dofile (getScriptPath() .. "\\window.lua")
dofile (getScriptPath() .. "\\portfolio.lua")
dofile (getScriptPath() .. "\\chart.lua")
dofile (getScriptPath() .. "\\label.lua")
dofile (getScriptPath() .. "\\risk.lua")
dofile (getScriptPath() .. "\\profit.lua")
dofile (getScriptPath() .. "\\action.lua")


orders.do_save = true
assets_delay = 0


processor:AddHandler("OnRun", function(t)
	assets_delay = false
end)


processor:AddInit(1, function()
	processor:InitLog(log_file)
	processor:SetTimer(500)
	message("Assets " .. lib:tostring(lib:GetAssets()) .. " Money " .. lib:tostring(lib:GetMoney()))
end)


processor:AddInit(1, function()
	if not lib:isConnected() then return true end
	if not lib:IsChartList("CHART") then return true end
	if not client_code then client_code = lib:GetUser() end
	if not client_code then return true end
	if not assets_delay then assets_delay = processor:GetTime(5000) end
	if not processor:IsDelay(assets_delay) then return true end
	
	if not script_id then script_id = client_code .. "#" .. script_name end
	if not log_file then log_file = lib.path.log .. script_id .. ".log" end
end)


processor:AddInit(function()
	lib:AddLine(lib.path.events .. "menu.start", lib:GetUser())
end)


processor:AddInit(function()
	processor:log("started")
end)


processor:AddTimer(function()
	for k, v in pairs(menu) do
		if type(v.changed) == "table" then
			v.changed = {}
		else
			v.changed = nil
		end
	end
end)


processor:AddTimer(function()
	collectgarbage("collect")
end)


end	-- of file

